package com.fanchuan.uzx.list.lecture;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.fanchuan.uzx.db.LectureDBDao;
import com.fanchuan.uzx.list.offer.OfferItemView;

public class LectureListAdapter  extends CursorAdapter {
	private LectureDBDao mLectureDBDao;
	public LectureListAdapter(Context context, Cursor c, LectureDBDao dao) {
		super(context, c, true);
		this.mLectureDBDao = dao;
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		if(view != null && view instanceof OfferItemView){
			bindItem((LectureItemView)view, cursor);
		}
		
	}

	void bindItem(LectureItemView itemView, Cursor cursor){
		itemView.bindItem(mLectureDBDao.readEntity(cursor, 0));
	}
	
	@Override
	public View newView(Context context, Cursor cursor, ViewGroup arg2) {
		LectureItemView itemView = LectureItemView_.build(context);
		bindView(itemView, context, cursor);
		return itemView;
	}

}
